package com.macro.mall.controller;

import com.macro.mall.common.api.CommonResult;
import com.macro.mall.dto.*;
import com.macro.mall.dto.DeviceRequest;
import com.macro.mall.service.AgentService;
import com.macro.mall.service.DeviceService;
import com.macro.mall.util.RequestData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author HuangZiy
 * @version 8.0
 * @date 2021/4/26 22:35
 */
@RestController
@RequestMapping(value = "/mms/mmsTerminal")
public class DeviceController {

    @Autowired
    private DeviceService deviceService;

    @GetMapping("/list")
    public CommonResult<List<Device>> getDevice(@RequestData DeviceRequest request) {
        return deviceService.getDevice(request);
    }


    @PostMapping
    public CommonResult<String> addDevice(@RequestBody DeviceRequest request) {
        return deviceService.addDevice(request);
    }

    @PutMapping("/{id}")
    public CommonResult<String> updateDevice(@PathVariable Integer id, @RequestBody DeviceRequest request) {
        return deviceService.updateDevice(request);
    }

    @DeleteMapping("/{id}")
    public CommonResult<String> deleteDevice(@PathVariable Integer id) {
        return deviceService.deleteDevice(id);
    }


}
